#!usr/bin/env python
# -*- coding:utf-8 _*-
"""
# author: 小菠萝测试笔记
# blog:  https://www.cnblogs.com/poloyy/
# time: 2021/10/17 5:52 下午
# file: conftest.py
"""
from typing import Any, Dict, Generator

import pytest
from fastapi.testclient import TestClient

from app.db.session import SessionLocal
from main import app
from tests.utils.testing_utils import *


@pytest.fixture(scope="session")
def db() -> Generator:
    yield SessionLocal()


@pytest.fixture(scope="session")
def client() -> TestClient:
    with TestClient(app=app) as client:
        yield client


@pytest.fixture(scope="module")
def get_header(client) -> Dict[str, str]:
    return get_superuser_token_headers(client)


@pytest.fixture(scope="module")
def get_user(client, get_header) -> Dict[str, Any]:
    return create_test_user(client, get_header)
